#!/bin/bash

REPOS_URL="https://gitee.com/wx-rdc/secloud-quickstart"

BASE_PATH="$HOME/.docker"

NETWORK_NAME="secloud-network"
MYSQL_DATA="secloud-db-data"
MYSQL_NAME="sec-mysql"
REDIS_NAME="sec-redis"
NACOS_NAME="sec-nacos"

# registry path
REGISTRY="svr01:5000"

SD_NAME="sec-device-security"
SD_VERSION="1.0.0"

MODULES="kun-system kun-auth kun-device kun-service-cipher kun-service-kms kun-gateway"
KUN_VERSION="1.2.0"

DASHBOARD_SERVICE_NAME="sec-dashboard-service"
DASHBOARD_SERVICE_VERSION="1.0.0"

DASHBOARD_WEBUI_NAME="sec-dashboard-webui"
DASHBOARD_WEBUI_VERSION="1.0.0"

# stop KUN containers & remove images
for module in $MODULES; do
    docker rm -f $module
    docker rmi $REGISTRY/$module:$KUN_VERSION
done

# stop dashboard containers & remove images
docker rm -f $DASHBOARD_SERVICE_NAME
docker rmi $REGISTRY/$DASHBOARD_SERVICE_NAME:$DASHBOARD_SERVICE_VERSION

docker rm -f $DASHBOARD_WEBUI_NAME
docker rmi $REGISTRY/$DASHBOARD_WEBUI_NAME:$DASHBOARD_WEBUI_VERSION

# stop sd containers & remove images
for id in `docker ps -q --filter name="$SD_NAME*"`; do
    docker rm -f $id
done
docker rmi $REGISTRY/$SD_NAME:$SD_VERSION